<template>
  <ul class="catagtory">
    <li
      :class="{'select': item.id === currentCategory}"
      v-for="item in categoryList"
      :key="item.id"
      @click="$store.commit('categtory/updateCurrentCategory', item.id)"
    >
      {{ item.name }}
    </li>
  </ul>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  created () {
    this.$store.dispatch('categtory/getCategoryList')
  },
  computed: {
    ...mapGetters(['categoryList', 'currentCategory'])
  },
  watch: {
    currentCategory (newVal) {
      this.$store.dispatch('list/getList', newVal)
    }
  }
}
</script>

<style>

</style>
